//
//  MoreViewController.swift
//  LaiLang
//
//  Created by David on 2017/2/3.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class MsgViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    var tableView: UITableView!
    var msgList: NSArray?
    
    var emptyLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        title = "消息"
        tableView = UITableView(frame: view.frame, style: .grouped)
        
        view.addSubview(tableView)
        
        msgList = NSArray(contentsOfFile: "\(CACHES_PATH)/msg/")
        
        emptyLabel = UILabel(frame: CGRect(x: 0, y: 64, width: view.bounds.width, height: 20))
        emptyLabel.text = emptyPlaceholder
        emptyLabel.textColor = UIColor.lightGray
        emptyLabel.textAlignment = .center
        emptyLabel.font = UIFont.systemFont(ofSize: 14)
        tableView.addSubview(emptyLabel)
        emptyLabel.alpha = 0
        
        var empty = true
        if msgList != nil {
            if msgList!.count != 0{
                empty = false
            }
        }
        if empty {
            emptyLabel.alpha = 1
        }
        
        tableView.delegate = self
        tableView.dataSource = self
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if msgList != nil {
            return msgList!.count
        }
        return 0
    }

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 64
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: .default, reuseIdentifier: "item")
        
        //    ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
        //    ┃  ┏━━━━┓ ┏━━━━━━━━━━━━━━━━┓  ┃8
        //  64┃48┃    ┃ ┗━━━━━━━━━━━━━━━━┛  ┃20
        //    ┃  ┃    ┃ ┏━━━━━━━━━━━━━━━━┓  ┃8
        //    ┃  ┗━━━━┛ ┗━━━━━━━━━━━━━━━━┛  ┃20
        //    ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛8
        //    |16| 48 |8|<--   label  -->|16|
        
        if msgList != nil {
            if msgList!.count != 0{
                
            }
        }
        
        
        
        return cell
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
